package com.demo.service.impl;

import com.demo.dto.ExcelReportDto;
import com.demo.entity.User;
import com.demo.service.ReportService;
import com.demo.service.UserDiseaseService;
import com.demo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ReportServiceImpl implements ReportService {
    @Autowired
    private UserService userService;
    @Autowired
    private UserDiseaseService userDiseaseService;

    @Override
    public void handleOneExcelReportData(ExcelReportDto data) {
        //保存User信息
        User user = new User();
        user.setName(data.getName());
        user.setAge(data.getAge());
        user.setSex(data.getSex());
        user = userService.saveOne(user);
        //保存患者疾病信息
        String dataModel = data.getDataModel();
        String osDisease = data.getOsDisease();
        userDiseaseService.handleUserDisease(user, dataModel, osDisease, "左眼");
        String odDisease = data.getOdDisease();
        userDiseaseService.handleUserDisease(user, dataModel, odDisease, "右眼");
        String bothDisease = data.getBothDisease();
        userDiseaseService.handleUserDisease(user, dataModel, bothDisease, "双眼");
    }
}
